package thread.noticywait;

public class ThreadNotify implements Runnable {
	private CommonEntity obj;

	public ThreadNotify(CommonEntity obj) {
		this.obj = obj;
	}

	public CommonEntity getObj() {
		return obj;
	}

	public void setObj(CommonEntity obj) {
		this.obj = obj;
	}

	@Override
	public void run() {
		synchronized (obj) {
			System.out.println("notify before");
			try {
				Thread.sleep(1000);
			} catch (InterruptedException e) {
				e.printStackTrace();
			}
			for (int i = 0; i < 100; i++) {
				if(i==5){
					obj.setI(i);
					obj.notify();
				}
			}
			obj.notify();
			System.out.println("notify after");
		}
	}

}
